package structure.flyweight.obj;

import structure.flyweight.abs.Website;

import java.util.HashMap;
import java.util.Map;

public class WebsiteFactory {
    // 集合，充当缓冲池的作用
    private static Map<String, Website> pool = new HashMap<>();

    // 从缓冲池中返回网站
    public static Website getWebsite(String type) {
        if (!pool.containsKey(type)) {
            pool.put(type, new ConcreteWebsite(type));
        }
        return pool.get(type);
    }
}
